package fr.playsoft.psas;

import android.app.Activity;
import android.os.Bundle;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;

public class SwipeImg extends Activity {
    
	/** Called when the activity is first created. */
	public void onCreate(Bundle icicle) {
		super.onCreate(icicle);
				
		setContentView(R.layout.fakeview);
		
	}
	
	private final GestureDetector gdt = new GestureDetector(new GestureListener());
	  
	  private class GestureListener extends SimpleOnGestureListener {

	     private final int SWIPE_MIN_DISTANCE = 120;
	     private final int SWIPE_THRESHOLD_VELOCITY = 200;
	 
	     @Override
	     public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
	        if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
	           // Right to left, your code here
	           return true;
	        } else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) >  SWIPE_THRESHOLD_VELOCITY) {
	           // Left to right, your code here
	           return true;
	        }
	        if(e1.getY() - e2.getY() > SWIPE_MIN_DISTANCE && Math.abs(velocityY) > SWIPE_THRESHOLD_VELOCITY) {
	           // Bottom to top, your code here
	           return true;
	        } else if (e2.getY() - e1.getY() > SWIPE_MIN_DISTANCE && Math.abs(velocityY) > SWIPE_THRESHOLD_VELOCITY) {
	           // Top to bottom, your code here
	           return true;
	        }
	        return false;
	     }
	  }
	
}